<?php
/**
 *	This file is part of rtfdoc.
 *
 *	rtfdoc is free software: you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License as published by
 *	the Free Software Foundation, either version 3 of the License, or
 *	(at your option) any later version.
 *
 *	rtfdoc is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with rtfdoc.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
require_once dirname(realpath(__FILE__)) . '/RTFDocumentView.php';
require_once dirname(realpath(__FILE__)) . '/RTFFont.php';
require_once dirname(realpath(__FILE__)) . '/RTFBody.php';
require_once dirname(realpath(__FILE__)) . '/RTFColor.php';
class RTFDocument
{
    const ALIGN_CENTER = 'center';
    const ALIGN_LEFT = 'left';
    const ALIGN_RIGHT = 'right';
    /**
     * holds the RTF text
     *
     * @var string
     */
    private $rtf_text;
    /**
     * holds a collection of RTFFont's
     *
     * @var array
     */
    private $fonts;
    /**
     * holds a collection of RTFColor's
     *
     * @var array
     */
    private $colors;
    /**
     * holds a collection of RTFBody's
     *
     * @var array
     */
    private $bodies;
    /**
     * adds a body to the output buffer
     *
     * @param RTFBody $body
     */
    public function addBody(RTFBody $body)
    {
        $this->bodies[] = $body;
    }
    /**
     * adds a header
     *
     * @param RTFBody $body
     * @param boolean $first_page_only
     * @param long $align
     *
     * // FIXME: this should be an RTFHeader object
     */
    public function addHeader(RTFBody $body, $first_page_only = false, $align = RTFDocument::ALIGN_CENTER)
    {
    }
    /**
     * adds a footer
     *
     * @param RTFBody $body
     * @param unknown_type $first_page_only
     * @param unknown_type $align
     *
     * // FIXME: this should be an RTFFooter object
     */
    public function addFooter(RTFBody $body, $first_page_only = false, $align = center)
    {
    }
    /**
     * adds a font to the fonttable
     *
     * @param RTFFont $font
     */
    public function addFont(RTFFont $font)
    {
        $this->fonts[] = $font;
    }
    /**
     * adds a color to the colortable
     *
     * @param RTFColor $color
     */
    public function addColor(RTFColor $color)
    {
        $this->colors[] = $color;
    }
    /**
     * adds an image
     *
     * @param RTFImage $image
     */
    public function addImage(RTFImage $image)
    {
    }
    /**
     * writes out document
     *
     * @param string $filename
     * @param boolean $to_browser
     */
    public function write($filename, $to_browser = false)
    {
        $view = new RTFDocumentView();
        $this->rtf_text = $view->parse($this);
        echo $this->rtf_text;
    }
    /**
     * returns collection of RTFFont's
     *
     * @return array
     */
    public function getFonts()
    {
        return $this->fonts;
    }
    /**
     * returns collection of RTFColor's
     *
     * @return array
     */
    public function getColors()
    {
        return $this->colors;
    }
    /**
     * returns collection of RTFBody's
     *
     * @return array
     */
    public function getBodies()
    {
        return $this->bodies;
    }
}
?>